package com.xinghen.provider.model.enums;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @author xinghen
 * @ClassName: UacGroupType
 * @Package: com.xinghen.provider.model
 * @Description uac group type enum
 * @create 2018-04-17 10:12
 */
public enum UacGroupType {

    GROUP_AREA("1", "大区"),
    GROUP_WAREHOUSE("2", "仓库"),
    GROUP_BASE("3", "基地"),
    GROUP_FRANCHISEE("5", "加盟商"),
    GROUP_OTHER("4", "其它"),;

    String key;
    String value;

    UacGroupType(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    /**
     * 获取key获取value
     *
     * @param key
     * @return
     */
    public static String getValue(String key) {
        for (UacGroupType ele : UacGroupType.values()) {
            if (key.equals(ele.getKey())) {
                return ele.getValue();
            }
        }
        return null;
    }

    /**
     * 根据key获取该对象
     *
     * @param key
     * @return
     */
    public static UacGroupType getGroupType(String key) {
        for (UacGroupType ele : UacGroupType.values()) {
            if (key.equals(ele.getKey())) {
                return ele;
            }
        }
        return null;
    }

    /**
     * 获取List集合
     *
     * @return
     */
    public static List<UacGroupType> getList() {
        return Arrays.asList(UacGroupType.values());
    }


    /**
     * 获取map类型集合
     *
     * @return
     */
    public static List<Map<String, String>> getMap2List() {
        List<Map<String, String>> list = Lists.newArrayList();
        for (UacGroupType ele : UacGroupType.values()) {
            Map<String, String> map = Maps.newHashMap();
            map.put("key", ele.getKey());
            map.put("value", ele.getValue());
            list.add(map);
        }
        return list;
    }

}
